define(function(require, exports, module) {
  "use strict";
  var Base = require("smartartBase");
  var LinkupModel = require("./model");

  var WIDGET_TYPE_LINEATION = 'lineation';
  var WIDGET_TYPE_BUTTON = 'button';
  var WIDGET_TYPE_ANSWER = 'saresult';
  var WIDGET_TYPE_ANSWER_STATISTICS = 'answerStatistics';

  module.exports = Base.SmartartBaseView.extend({
    initialize: function(config, options) {
      this.linkupModel = new LinkupModel({});

      // 创建widget的时候
      var isFirstCreate = !config.itemId;

      if (isFirstCreate) {
        config.position = {top: 200, left: 100}; 
        this.isFirstCreate = true;
      }
      Base.SmartartBaseView.prototype.initialize.apply(this, arguments);

      if (isFirstCreate) {
        this.firstInit();
      } else {
        this.init();
      }
      this.fitSize();
    },

    // 初次创建的连线题的初始化
    firstInit: function() {
      this.createAnswerWidget();
      this.createToolbar();
      this.initLayoutData();
      this.layout();
      this.makeSignalSlot();
    },

    // 已有连线题的初始化
    init: function() {
      // 转换老版本连线题的数据
      if (!this.getData('leftItems')) {
        this.covertDataOfOldVersion();
      }
      this.initLayoutData();
    },

    covertDataOfOldVersion: function() {
      var resetBtnId = this.getData('_reset');
      var checkBtnId = this.getData('_check');
      var answerBtnId = this.getData('_correct');
      var answerWidgetId = this.getWidgetData('_answerId');

      var columns = this.generateColumnsData();
      var buttons = [{itemId: resetBtnId, type: WIDGET_TYPE_BUTTON, btnType: 'reset'},
                     {itemId: checkBtnId, type: WIDGET_TYPE_BUTTON, btnType: 'check'},
                     {itemId: answerBtnId, type: WIDGET_TYPE_BUTTON, btnType: 'answer'}];
      var answer = {itemId: answerWidgetId, type: WIDGET_TYPE_ANSWER};

      columns = this.normalizeColumnsData(columns);

      this.setData('leftItems', columns[0].length);
      this.setData('middleItems', columns[1].length);
      this.setData('rightItems', columns[2].length);
      this.setData('leftItemWidth', 200);
      this.setData('leftItemHeight', 108);
      this.setData('middleItemWidth', 200);
      this.setData('middleItemHeight', 108);
      this.setData('rightItemWidth', 200);
      this.setData('rightItemHeight', 108);
      this.setData('lineSpace', 20);
      this.setData('columnSpace', 60);
      this.setData('buttons', buttons);
      this.setData('answer', answer);
    },

    // 已有控件的初始化
    initLayoutData: function() {
      this.linkupModel.set('leftItems', this.getData('leftItems') || 1);
      this.linkupModel.set('middleItems', this.getData('middleItems') || 0);
      this.linkupModel.set('rightItems', this.getData('rightItems') || 1);
      this.linkupModel.set('leftItemWidth', this.getData('leftItemWidth') || 200);
      this.linkupModel.set('leftItemHeight', this.getData('leftItemHeight') || 108);
      this.linkupModel.set('middleItemWidth', this.getData('middleItemWidth') || 200);
      this.linkupModel.set('middleItemHeight', this.getData('middleItemHeight') || 108);
      this.linkupModel.set('rightItemWidth', this.getData('rightItemWidth') || 200);
      this.linkupModel.set('rightItemHeight', this.getData('rightItemHeight') || 108);
      this.linkupModel.set('lineSpace', this.getData('lineSpace') || 20);
      this.linkupModel.set('columnSpace', this.getData('columnSpace') || 60);
      this.linkupModel.set('itemBackgroundColor', this.getData('itemBackgroundColor') || 'rgb(0,160,234)');
      this.linkupModel.set('connectMode', this.getData('connectMode') || 'leftright');
      this.linkupModel.set('hasAnswerStatistics', this.getData('hasAnswerStatistics') === undefined ? false : this.getData('hasAnswerStatistics'));
    },

    // 更新用于layout的columns数据
    // [
    //   [itemId, itemId, ...],
    //   [itemId, itemId, ...],
    //   ...
    // ]
    updateLayoutData: function() {
      var columns = this.generateColumnsData();
      var numberOfLeftItems = this.linkupModel.get('leftItems');
      var numberOfMiddleItems = this.linkupModel.get('middleItems');
      var numberOfRightItems = this.linkupModel.get('rightItems');

      columns = this.normalizeColumnsData(columns);

      this.syncColumnItems(columns, 0, numberOfLeftItems);
      this.syncColumnItems(columns, 1, numberOfMiddleItems);
      this.syncColumnItems(columns, 2, numberOfRightItems);

      for (var i = columns.length - 1; i >= 0; i--) {
        if (columns[i].length === 0) {
          columns.splice(i, 1);
        }
      }

      this.linkupModel.set('columns', columns);
      return columns;
    },

    // 将columns补成3列 (左/中/右)，没有项目的插入空数组 以方便计算
    normalizeColumnsData: function(columns) {
      if (!columns || columns.length === 0) {
        columns = [[], [], []];
      } else if (columns.length === 1) {
        columns = columns.concat([[], []]);
      } else if (columns.length === 2) {
        columns.splice(1, 0, []);
      }
      return columns;
    },

    // 根据用户设置的每列的项目个数，添加/删除对应列的连线项目
    syncColumnItems: function(columns, columnIndex, newNumber) {
      if (columns[columnIndex].length < newNumber) {
        for (var i = 0, length = newNumber - columns[columnIndex].length; i < length; i++) {
          var itemWidget = this.createLineationWidget();
          columns[columnIndex].push(itemWidget.model.get('itemId'));
          this.makeSignalSlot();
        }
      } else if (columns[columnIndex].length > newNumber) {
        for (var i = 0, length = columns[columnIndex].length - newNumber; i < length; i++) {
          this.getWidgetByItemId(columns[columnIndex].pop()).remove();
        }
      }
    },

    // 从连线项目的位置信息生成 columns 数据
    // [
    //   [itemId, itemId, ...],
    //   [itemId, itemId, ...],
    //   ...
    // ]
    generateColumnsData: function() {
      var widgets = this.children.filter(function(widget) {
        return widget.model.get('type') === WIDGET_TYPE_LINEATION;
      });
      var widgetPositionMap = {};
      var columns = [];
      var itemId, itemPos, itemSize, inColumnItemPos;
      var i, j, k, length, lengthj, index, found;
      var delta = 50;

      for (i = 0, length = widgets.length; i < length; i++) {
        itemId = widgets[i].model.get('itemId');
        itemPos = widgets[i].model.get('position');
        itemSize = widgets[i].model.get('size');
        widgetPositionMap[itemId] = {
          left: itemPos.left,
          top: itemPos.top,
          right: itemPos.left + itemSize.width,
          center: itemPos.left + itemSize.width / 2
        };
      }

      for (i = 0, length = widgets.length; i < length; i++) {
        itemId = widgets[i].model.get('itemId');
        itemPos = widgets[i].model.get('position');
        itemSize = widgets[i].model.get('size');
        found = false;
        for (j = 0, lengthj = columns.length; j < lengthj; j++) {
          index = columns[j].length - 1;
          if (index < 0) continue;
          inColumnItemPos = widgetPositionMap[columns[j][index]];
          if (Math.abs(inColumnItemPos.left - itemPos.left) < delta ||
              Math.abs(inColumnItemPos.right - (itemPos.left + itemSize.width)) < delta ||
              Math.abs(inColumnItemPos.center - (itemPos.left + itemSize.width / 2)) < delta) {
            columns[j].push(itemId);
            found = true;
            break;
          }
        }
        if (!found) {
          columns.push([itemId]);
        }
      }

      // 按位置顺序排列各列
      for (i = 0, length = columns.length; i < length; i++) {
        for (j = i + 1; j < length; j++) {
          if (widgetPositionMap[columns[j][0]].left < widgetPositionMap[columns[i][0]].left) {
            columns.splice(i, 0, columns.splice(j, 1)[0]);
          }
        }
        for (j = 0, lengthj = columns[i].length; j < lengthj; j++) {
          for (k = j + 1; k < lengthj; k++) {
            if (widgetPositionMap[columns[i][k]].top < widgetPositionMap[columns[i][j]].top) {
              columns[i].splice(j, 0, columns[i].splice(k, 1)[0]);
            }
          }
        }
      }

      return columns;
    },

    // 创建连线项目控件
    createLineationWidget: function() {
      var lineationWidget;
      lineationWidget = this.create("item", {type: WIDGET_TYPE_LINEATION});
      lineationWidget.model.set({
          hasSignalSlot: false
        });
      this.addChild(lineationWidget);
      return lineationWidget;
    },
    // 创建答案控件
    createAnswerWidget: function() {
      var answerWidget = this.create("item", {type: WIDGET_TYPE_ANSWER});
      answerWidget.model.set({
        hasSignalSlot: false,
        hasDelete: false
      });
      this.addChild(answerWidget);
      this.setData('answer', {itemId: answerWidget.model.get('itemId'), type: WIDGET_TYPE_ANSWER});
      return answerWidget;
    },
    // 创建按钮控件
    createBtnWidget: function(text, bgImage) {
        var button = this.create("item", {type: WIDGET_TYPE_BUTTON});
        button.model.set({
          hasSignalSlot: false,
          hasDelete: false
        });
        this.addChild(button);
        button.dataChange({name: "text", value: text}, button.itemId, true);
        button.dataChange({name: "bgImage", value: bgImage}, button.itemId, true);
        return button;
    },
    // 创建答题统计控件
    createAnswerStatisticsWidget: function() {
      var widget = this.create("item", {type: WIDGET_TYPE_ANSWER_STATISTICS});
      widget.model.set({
        hasSignalSlot: false,
        hasDelete: false
      });
      widget.dataChange({name: "showTitle", value: false}, widget.itemId, true);
      widget.model.set("size", { width: 280, height: 60});
      this.addChild(widget);
      return widget;
    },

    // 创建右上角的工具栏
    createToolbar: function() {
      var resetBtn, checkBtn, answerBtn;
      resetBtn = this.createBtnWidget("重置", "icon6");
      checkBtn = this.createBtnWidget("检查", "icon3");
      answerBtn = this.createBtnWidget("答案", "icon10");

      this.setData('buttons', [
        {itemId: resetBtn.model.get('itemId'), type: WIDGET_TYPE_BUTTON, btnType: 'reset'},
        {itemId: checkBtn.model.get('itemId'), type: WIDGET_TYPE_BUTTON, btnType: 'check'},
        {itemId: answerBtn.model.get('itemId'), type: WIDGET_TYPE_BUTTON, btnType: 'answer'}
      ]);
    },

    /**
     * 创建连线题的时候会做 layout
     * 但是初始化已有连线题的时候不做 layout
     * 改变连线题属性的时候会做 layout
     * 用户移除连线项目的时候会做 layout
     */
    layout: function() {
      var lineSpace = this.linkupModel.get('lineSpace');
      var columnSpace = this.linkupModel.get('columnSpace');
      var startPos;
      var itemSize, totalWidth, numberOfColumns, columns;

      // layout的时候可能会移除连线项，进而触发 removeChild方法被调用
      // 设置此标志位 this.isLayouting 让removeChild方法在此时不要做 layout
      this.isLayouting = true;

      this.updateLayoutData();
      columns = this.linkupModel.get('columns');
      numberOfColumns = columns.length;
      this.layoutToolbar();

      // 第一次创建连线题控件组的时候，工具栏按钮默认在右上方
      if (this.isFirstCreate) {
        startPos = {left: 0, top: 100};
      } else {
        startPos = this.getWidgetByItemId(columns[0][0]).model.get('position');
      }

      for (var i = 0; i < numberOfColumns; i++) {
        itemSize = this.getItemSizeByColumn(i);
        this.layoutColumn(i, startPos, lineSpace, itemSize.width, itemSize.height);
        startPos.left += itemSize.width + columnSpace;
      }

      this.fitSize();

      this.isLayouting = false;
    },

    layoutColumn: function(columnIndex, startPos, lineSpace, itemWidth, itemHeight) {
      var itemIds, itemWidget, itemPosX, itemPosY, columnName, columnWidth, itemSize, previousItemSize;
      itemIds = this.linkupModel.getItemIdsByColumn(columnIndex);
      itemPosY = startPos.top;
      columnName = this.getColumnName(columnIndex);
      for (var i = 0, length = itemIds.length; i < length; i++) {
        itemWidget = this.getWidgetByItemId(itemIds[i]);
        itemWidget.model.set('size', {width: itemWidth, height: itemHeight});
        itemWidget.model.set('displayName', this.model.get('displayName') + '-' + columnName + (i + 1));
        itemPosX = startPos.left;
        this.setWidgetPosition(itemIds[i], {top: itemPosY, left: itemPosX});
        itemPosY += itemHeight + lineSpace;
      }
    },

    layoutToolbar: function() {
      var buttons = this.getData('buttons');
      var btnWidget;
      var shouldUpdateBtnPos = true;
      var i, length;
      for (i = 0, length = buttons.length; i < length; i++) {
        btnWidget = this.getWidgetByItemId(buttons[i].itemId);
        // 所有按钮的位置都位于默认位置时才更新layout
        // 否则不做更新 (因为用户手动调整了按钮的位置)
        if (buttons[i].normalPosition && 
            (buttons[i].normalPosition.top !== btnWidget.model.get('position').top ||
            buttons[i].normalPosition.left !== btnWidget.model.get('position').left)) {
          shouldUpdateBtnPos = false;
        }
      }

      if (!shouldUpdateBtnPos) return;

      // 工具栏按钮默认位置位于右上方
      var defaultBtnPos = this.getDefaultBtnPos();
      for (i = 0, length = buttons.length; i < length; i++) {
        btnWidget = this.getWidgetByItemId(buttons[i].itemId);
        this.setWidgetPosition(btnWidget.itemId, defaultBtnPos[buttons[i].btnType]);
        buttons[i].normalPosition = defaultBtnPos[buttons[i].btnType];
      }
      // 保存按钮的默认位置
      this.setData('buttons', buttons);
    },

    updateItemBackgroundColor: function() {
      var columns = this.linkupModel.get('columns');
      var backgroundColor = this.linkupModel.get('itemBackgroundColor');
      var itemId;
      var itemWidget;
      for (var i = 0; i < columns.length; i++) {
        for (var j = 0; j < columns[i].length; j++) {
          itemId = columns[i][j];
          itemWidget = this.getWidgetByItemId(itemId);
          itemWidget.dataChange({name: "backgroundColor", value: backgroundColor}, itemId, true);
        }
      }
    },

    updateItemConnectMode: function() {
      var columns = this.linkupModel.get('columns');
      var connectMode = this.linkupModel.get('connectMode');
      var itemId;
      var itemWidget;
      for (var i = 0; i < columns.length; i++) {
        for (var j = 0; j < columns[i].length; j++) {
          itemId = columns[i][j];
          itemWidget = this.getWidgetByItemId(itemId);
          itemWidget.dataChange({name: "connectMode", value: connectMode}, itemId, true);
        }
      }
    },

    // 获取包括所有连线项目在内的宽度
    getTotalWidth: function() {
      var numberOfColumns, columnSpace, totalWidth;
      var itemSize;
      totalWidth = 0;
      columnSpace = this.linkupModel.get('columnSpace');
      numberOfColumns = this.linkupModel.get('columns').length;
      for (var i = 0; i < numberOfColumns; i++) {
        itemSize = this.getItemSizeByColumn(i);
        totalWidth += itemSize.width + columnSpace;
      }
      totalWidth -= columnSpace;
      return totalWidth;
    },

    // 默认工具栏按钮位置位于右上方
    getDefaultBtnPos: function() {
      var totalWidth = this.getTotalWidth();
      return {
        reset: {top: 0, left: totalWidth - 280},
        check: {top: 0, left: totalWidth - 180},
        answer: {top: 0, left: totalWidth - 80}
      };
    },

    getDefaultAnswerStatisticsWidget: function() {
      var totalWidth = this.getTotalWidth();
      return {top: 0, left: totalWidth + 20};
    },

    // 根据列索引号获取用户设置的列的宽度
    getItemSizeByColumn: function(columnIndex) {
      var columns;
      if (columnIndex === 0) {
        return {
          width: this.linkupModel.get('leftItemWidth'),
          height: this.linkupModel.get('leftItemHeight')
        };
      } else if (columnIndex === 1) {
        columns = this.linkupModel.get('columns');
        if (columns.length === 2) {
          return {
            width: this.linkupModel.get('rightItemWidth'),
            height: this.linkupModel.get('rightItemHeight')
          }
        }
        return {
          width: this.linkupModel.get('middleItemWidth'),
          height: this.linkupModel.get('middleItemHeight')
        }
      }
      return {
        width: this.linkupModel.get('rightItemWidth'),
        height: this.linkupModel.get('rightItemHeight')
      }
    },

    getColumnName: function(columnIndex) {
      var hasMiddleColumn, columnName;
      hasMiddleColumn = (this.linkupModel.get('columns').length >= 3);
      if (columnIndex === 0) {
        columnName = '左';
      } else if (columnIndex === 1) {
        if (hasMiddleColumn) {
          columnName = '中';
        } else {
          columnName = '右'
        }
      } else if (columnIndex === 2 && hasMiddleColumn) {
        columnName = '右';
      } else {
        columnName = '第' + (columnIndex + 1) + '列';
      }

      return columnName;
    },

    getWidgetByItemId: function(itemId) {
      return this.children.filter(function(child) {
        return child.itemId === itemId;
      })[0];
    },

    getButtonItemId: function(btnType) {
      var buttons = this.getData('buttons');
      for (var i = 0, length = buttons.length; i < length; i++) {
        if (buttons[i].btnType === btnType) {
          return buttons[i].itemId;
        }
      }
    },

    setWidgetPosition: function(itemId, pos) {
      var widget = this.getWidgetByItemId(itemId);
      widget.model.set('position', pos);
      widget.trigger('fitSize');
      this.linkupModel.setWidgetData(itemId, {position: pos});
    },

    // hook: 当智能控件组的子控件被移除时，该方法被调用
    removeChild: function(view) {
      var itemId, widgetData;
      Base.SmartartBaseView.prototype.removeChild.apply(this, [view]);
      if (this.isRemovingSmartart) return;
      if (!this.isLayouting) this.layout();
    },

    // hook: 当智能控件组被移除时，该方法被调用，removeChild也会因此被逐一调用
    remove: function() {
      this.isRemovingSmartart = true;
      Base.SmartartBaseView.prototype.remove.apply(this, arguments);
      this.isRemovingSmartart = false;
    },

    setData: function(type, value) {
      var data = this.getSelfData();
      data[type] = value;
      this.setSelfData(data);
    },
    getData: function(type) {
      var data = this.getSelfData();
      return data[type];
    },
    handleItemSizeChange: function(item, size) {
    },

    switchAnswerStatistics: function() {
      var hasAnswerStatistics = this.linkupModel.get('hasAnswerStatistics');
      if (hasAnswerStatistics) {
        if (this.getData('answerStatisticsItemId')) return;
        var widget = this.createAnswerStatisticsWidget();
        this.setData('answerStatisticsItemId', widget.itemId);
        this.setWidgetPosition(widget.itemId, this.getDefaultAnswerStatisticsWidget());
        this.makeSignalSlot();
      } else {
        var id = this.getData('answerStatisticsItemId');
        if (!id) return;
        this.getWidgetByItemId(id).remove();
        this.setData('answerStatisticsItemId', null);
      }
    },

    updateScore: function(score) {
      var itemId = this.getData('answer').itemId;
      var answerWidget = this.getWidgetByItemId(itemId);
      if (answerWidget) answerWidget.dataChange({name: 'score', value: score}, itemId, true);
    },

    refreshUI: function(data) {
      var shouldUpdateAnswer = false;
      var orginalData = data;

      data = this.formatAttributeData(data);

      if (data.leftItems !== undefined && data.leftItems >= 1 && data.leftItems !== this.linkupModel.get('leftItems')) {
        this.linkupModel.set('leftItems', data.leftItems);
        shouldUpdateAnswer = true;
      }

      if (data.leftItemWidth !== undefined && data.leftItemWidth !== this.linkupModel.get('leftItemWidth')) {
        this.linkupModel.set('leftItemWidth', data.leftItemWidth);
      }

      if (data.leftItemHeight !== undefined && data.leftItemHeight !== this.linkupModel.get('leftItemHeight')) {
        this.linkupModel.set('leftItemHeight', data.leftItemHeight);
      }

      if (data.middleItems !== undefined && data.middleItems >= 0 && data.middleItems !== this.linkupModel.get('middleItems')) {
        this.linkupModel.set('middleItems', data.middleItems);
        shouldUpdateAnswer = true;
      }

      if (data.middleItemWidth !== undefined && data.middleItemWidth !== this.linkupModel.get('middleItemWidth')) {
        this.linkupModel.set('middleItemWidth', data.middleItemWidth);
      }

      if (data.middleItemHeight !== undefined && data.middleItemHeight !== this.linkupModel.get('middleItemHeight')) {
        this.linkupModel.set('middleItemHeight', data.middleItemHeight);
      }

      if (data.rightItems !== undefined && data.rightItems >= 1 && data.rightItems !== this.linkupModel.get('rightItems')) {
        this.linkupModel.set('rightItems', data.rightItems);
        shouldUpdateAnswer = true;
      }

      if (data.rightItemWidth !== undefined && data.rightItemWidth !== this.linkupModel.get('rightItemWidth')) {
        this.linkupModel.set('rightItemWidth', data.rightItemWidth);
      }

      if (data.rightItemHeight !== undefined && data.rightItemHeight !== this.linkupModel.get('rightItemHeight')) {
        this.linkupModel.set('rightItemHeight', data.rightItemHeight);
      }

      if (data.lineSpace !== undefined && data.lineSpace !== this.linkupModel.get('lineSpace')) {
        this.linkupModel.set('lineSpace', data.lineSpace);
      }

      if (data.columnSpace !== undefined && data.columnSpace !== this.linkupModel.get('columnSpace')) {
        this.linkupModel.set('columnSpace', data.columnSpace);
      }

      this.layout();
      
      if (data.itemBackgroundColor !== undefined && data.itemBackgroundColor !== this.linkupModel.get('itemBackgroundColor')) {
        this.linkupModel.set('itemBackgroundColor', data.itemBackgroundColor);
        this.updateItemBackgroundColor();
      }
      
      if (data.connectMode !== undefined && data.connectMode !== this.linkupModel.get('connectMode')) {
        this.linkupModel.set('connectMode', data.connectMode);
        this.updateItemConnectMode();
      }

      if (data.hasAnswerStatistics !== undefined && data.hasAnswerStatistics !== this.linkupModel.get('hasAnswerStatistics')) {
        this.linkupModel.set('hasAnswerStatistics', data.hasAnswerStatistics);
        this.switchAnswerStatistics();
      }

      if (data.score !== undefined) {
        this.updateScore(data.score);
      }

      if (shouldUpdateAnswer) {
        this.updateAnswer();
      }

      Base.SmartartBaseView.prototype.refreshUI.apply(this, [orginalData]);
    },
    formatAttributeData: function(data) {
      var obj = {};
      data.forEach(function(item) {
        obj[item.name] = item.value;
      });
      return obj;
    },
    updateAnswer: function() {
      var answerWidgetItemId = this.getData('answer').itemId;
      var existedItemId = [];

      this.linkupModel.get('columns').forEach(function(column) {
        existedItemId = existedItemId.concat(column);
      });

      // remove data from saresult
      var data = this.getWidgetData(answerWidgetItemId);
      var newAnswer = [];

      if (!data.answer) {
        data.answer = [];
      }

      // 只保留两个连线项目都存在的答案
      data.answer.forEach(function(item) {
        if (existedItemId.indexOf(item.option1) > -1 &&
          existedItemId.indexOf(item.option2) > -1) {
          newAnswer.push(item);
        }
      });
      data.answer = newAnswer;
      this.setWidgetData(answerWidgetItemId,data);
    },

    makeSignalSlot: function() {
      var signals = [];
      var resetBtnId, checkBtnId, answerBtnId, answerWidgetId, answerStatisticsId, lineations;

      resetBtnId = this.getButtonItemId('reset');
      checkBtnId = this.getButtonItemId('check');
      answerBtnId = this.getButtonItemId('answer');
      answerWidgetId = this.getData('answer').itemId;
      answerStatisticsId = this.getData('answerStatisticsItemId');

      lineations = this.children.filter(function(item) {
        return item.model.get('type') === WIDGET_TYPE_LINEATION;
      });

      // create the signal-slot list
      lineations.forEach(function(item) {
        //点击每个项目，所有项目会收到项目被点击信号
        lineations.forEach(function(slot) {
          signals.push([item.itemId, "click.lineation", slot.itemId, "receiveSignal"]);
        });
        //点击项目时突出显示该项目
        signals.push([item.itemId, "click.lineation", answerWidgetId, "spotLight"]);
        signals.push([item.itemId, "drawEnable.lineation", answerWidgetId, "drawEnable"]);
        signals.push([answerWidgetId, "draw.saresult", item.itemId, "draw"]);
        signals.push([answerWidgetId, "reset.saresult", item.itemId, "reset"]);
      });


      signals.push([resetBtnId, "clicked.button", answerWidgetId, "reset"]);
      signals.push([answerBtnId, "clicked.button", answerWidgetId, "correct"]);
      signals.push([checkBtnId, "clicked.button", answerWidgetId, "check"]);
      if (answerStatisticsId) {
        signals.push([answerWidgetId, "correct.saresult", answerStatisticsId, "receiveAnswer"]);
        signals.push([answerWidgetId, "wrong.saresult", answerStatisticsId, "receiveAnswer"]);
        signals.push([resetBtnId, "clicked.button", answerStatisticsId, "reset"]);
      }
      // send signal-slot to signal-slot manager
      this.sendSignalSlot(signals);
    }
  });

});
